#include <stdio.h>
#include <stdlib.h>
#include "japi.h"
#include "indivResultsData.h"
#include "filecontrol.h"
#include <string.h>

int openIndividualResultScreen(student_t student)
{
    int frame,button;
    int listresults,obj;
    int firstNameLabel,surNameLabel,idNumLabel;

    int i;
    char displayString[50];
    char gradeString[4];


    frame=j_frame("Individual Results");
    j_setsize(frame,600,600);


    button = j_button(frame,"Back");

    j_setsize(button,80,20);
    j_setpos(button,200,500);

    firstNameLabel = j_label(frame,student.firstName);
    surNameLabel = j_label(frame,student.surName);
    idNumLabel = j_label(frame,student.id);

    j_setpos(firstNameLabel,100,150);
    j_setsize(firstNameLabel,50,20);

    j_setpos(surNameLabel,150,150);
    j_setsize(surNameLabel,75,20);

    j_setpos(idNumLabel,100,180);
    j_setsize(idNumLabel,75,20);


    listresults= j_list(frame,3);

    j_setcolor(listresults, 150, 0, 0);

    //Fill modules and grades arrays
    getGrades("1234");

    for(i = 0; i < getNumModules(); i++)
    {
        strcpy(displayString, modules[i]);
        strcat(displayString, ": ");

        sprintf(gradeString, "%d", grades[i]);

        strcat(displayString, gradeString);

        j_additem(listresults, displayString);

    }


    j_setpos(listresults,350,150);

    j_show(frame);

    while(1)
    {
        obj=j_nextaction();

        if(obj==button)
        {
            j_hide(frame);
            //showResultsSelectStudent();
        }
        else if(obj==frame)
        {
            j_quit();
        }

    }


    return 0;
}
